#!/bin/sh
# Log some extra information at the beginning of a suspend/resume cycle.
# TODO: Make this hook only run when PM_DEBUG is true?

. "${PM_FUNCTIONS}"

echo "!!! wifibt $1 $2 !!!" > /dev/kmsg

#wlan=$(ifconfig | grep wlp1s0)
hci=$(hciconfig | grep hci)

case "$1" in
       hibernate|suspend)
		if [ ! -z "$hci" ]; then
			hciconfig hci0 down
		fi
		#if [ ! -z "$wlan" ]; then
		#	ifconfig wlp1s0 down
		#fi
               ;;
       thaw|resume)
		#if [ ! -z "$wlan" ]; then
		#	ifconfig wlp1s0 up
		#fi
		if [ ! -z "$hci" ]; then
			hciconfig hci0 up
		fi
               ;;
       *) exit $NA
               ;;
esac
